package com.logistic.service.impl;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.logistic.dao.AddressDao;
import com.logistic.dao.RecordDao;
import com.logistic.dao.UserDao;
import com.logistic.domain.PickupAddressCN;
import com.logistic.domain.Record;
import com.logistic.service.AddressService;


@Service
public class AddressServiceImpl implements AddressService {

	@Autowired
	private AddressDao addressDao;
	


	/**
	 * 查询所有记录
	 * @param sort 排序字段
	 * @return
	 */
	public List findRecordAll(String sort) {
		
		List list = new ArrayList();
		list = addressDao.getAll();
		return list;
	}
	
	public List findAddressByUid(String uId){
		List list = new ArrayList();
		list = addressDao.getAllByUid(uId);
		return list;
	}
	public PickupAddressCN queryAddress(String addrId){
		return addressDao.queryAddress(addrId);
	}
	
	/**
	 * 保存
	 */
	public String save(PickupAddressCN addr) {
	
		int num = addressDao.save(addr);
		if(num > 0) {
			return "ok";
		} else {
			return "error";
		}
		
	}
	
	/**
	 * 修改
	 */
	public String modify(PickupAddressCN addr) {
		
		addressDao.modify(addr);
		return "ok";
	}
	
	/**
	 * 根据xh删除Record
	 * @return
	 */
	public void deleteByIdStr(String idStr) {
		String[] ids = idStr.split(","); 
		for(int i = 0; i < ids.length; i++) {
			addressDao.delete(ids[i]);
		}
	}

	
	public AddressDao getAddressDao() {
		return addressDao;
	}

	public void setAddressDao(AddressDao addressDao) {
		this.addressDao = addressDao;
	}

}
